# coding: utf-8

# import crypt
import random
import string
import hashlib
import base64


class EnCryPt(object):
    """
    加密解密类
    """

    def __init__(self):
        pass

    def _getsalt(self, chars=string.ascii_letters + string.digits):
        return random.choice(chars) + random.choice(chars)

    def encrypt(self, string):
        m = hashlib.md5()
        m.update(string.encode("utf8"))
        pwd = m.hexdigest()

        return pwd

    def enbase64(self, string):

        target = base64.b64encode(string.encode('UTF-8'))
        return target

    def debase64(self, string):
        """解密"""
        target = base64.b64decode(string).decode('UTF-8')
        return target


if __name__ == '__main__':
    e = EnCryPt()
    print(e.enbase64('FoAeFxLcMwybinXL'))

    print(e.debase64(b'Rm9BZUZ4TGNNd3liaW5YTA=='))
